﻿#light

open Turtle
open FsxUnit.Syntax
open Common.Monads.State

//Construct
let ATurtle () = new TurtleImmutable() // Turtle as a Value Object


//MoveTurtle
let MovesOneStepForward : Common.Monads.State<TurtleImmutable, unit> =  
 state { 
    let! (t : TurtleImmutable) = GetState
    do! SetState <| t.Go()
 }

let IsMovedOneStepForward = 
 state {
    let! (t : TurtleImmutable) = GetState
    t.Position.X |> should equal 1
 }
 
let RotationIs angle = 
 state {
    let! (t : TurtleImmutable) = GetState
    t.Direction |> should equal 0.0
 }


//MoveTurtleToPosition
let IsRotated90DegreesToTheRight = 
 state {
    let! (t : TurtleImmutable) = GetState
    do! SetState <| t.Left()
 }
let TurtleWalksSteps steps = 
 state {
    let! (t : TurtleImmutable) = GetState
    do! SetState <| t.GoSteps(steps)
 }
 
let TurtleIsLocatedAt (x,y) = 
 state {
  let! (t: TurtleImmutable) = GetState
  t.Position |> should equal (new Position(x,y))
 }
